﻿@{
    Layout = "~/Areas/Web/Views/Shared/_UserCenter.cshtml";
    ViewBag.Title = "商品咨询";
}
@model IEnumerable<Himall.Model.ProductEvaluation>

<div class="box1 lh24">
    <div class="title bot-border">
        <h3 class="title_txt cur">满意度评价</h3>
    </div>
    
    <div class="border-box">
        <table class="tb-void tb-line" width="100%" cellspacing="0" cellpadding="0" border="0">
            <colgroup>
                <col width="430">
                <col width="130">
                <col width="134">
                <col>
            </colgroup>
            <thead>
                <tr>
                    <th>订单编号</th>
                    <th>状态</th>
                    <th>评价时间</th>
                    <th>评价</th>
                </tr>
            </thead>
            <tbody>
                @if (Model.Count() == 0)
                {
                    <tr><td colspan="4"><div class="empty"><b></b>暂时没有评论记录</div></td></tr>
                }
                @{var i = 0;}
                @foreach (var m in Model)
                {
                    i++;
                    <tr>
                        <td>
                            <a href="@Url.Action("Detail", "UserOrder", new { id = @m.OrderId })">@m.OrderId</a>
                        </td>
                        <td>
                            @if (m.EvaluationStatus)
                            {
                                <strong state="ddfk" class="ftx-02 order-statu">已评价</strong>
                            }
                            else
                            {
                                <strong state="ddfk" class="ftx-04 order-statu">未评价</strong>
                            }
                        </td>
                        <td>
                            @if (!m.BuyTime.Equals(DateTime.MinValue))
                            {
                                <span class="ftx03">@m.BuyTime</span>
                            }
                        </td>  
                        <td>

                            @if (m.EvaluationStatus)
                            {
                                <a href="@Url.Action("Details", "OrderEvaluation", new { orderId = @m.OrderId })" class="pj" title="已评价" catethird="0">查看评价</a><br>
                            }
                            else
                            {
                                <a catethird="@m.Id" class="id_sub" title="发评价" class="pj" href="@Url.Action("Index", "OrderEvaluation", new { id = @m.OrderId })">
                                发表评价<b class="icon-show"></b>
                                </a>
                            }
                        </td>
                    </tr>

                }
            </tbody>
        </table>
        <div class="mt10 clearfix">
            <div class="m clearfix" id="bottom_pager">
                <div id="pagin-btm" class="pagin fr" style="clear:both">
                    @{
                        var count = ((PagingInfo)ViewBag.pageInfo).TotalPages;
                        var curr = ((PagingInfo)ViewBag.pageInfo).CurrentPage;
                    }
                    @Html.PageLinks((PagingInfo)ViewBag.pageInfo, x => Url.Action("Index", new { pageNo = x }))
                    <span class="page-skip">
                        <em>&nbsp;&nbsp;共 @count 页&nbsp;&nbsp;&nbsp;&nbsp;</em>
                    </span>
                </div>
            </div>
            <!--pagin end-->
        </div>
    </div>


</div>
<script>
    (function ($) {
        var star = '',
            uid = '862',
            cont = '';
        $('.commstar').children().each(function (i, e) {
            var obj = $(e);
            obj.bind('click', function () {
                obj.siblings().removeClass('active');
                obj.addClass('active');
                var a = obj.attr('data');
                if (a != uid) {
                    cont = '';
                    star = '';
                    uid = a;
                }
                star = obj.attr('data-t');
                obj.parent().attr('data', star);
            });
        });
        $('.id_cont_txt').each(function (i, e) {
            $(e).focus(function () {
                $(e).val('');
                $(e).removeClass('area01');
            }).blur(function () {
                var a = $(e).attr('data');
                if (a != uid) {
                    cont = '';
                    star = '';
                    uid = a;
                }
                cont = $(e).val();
                if ($(e).val()) {
                    //
                } else {
                    $(e).addClass('area01');
                    $(e).val('商品是否给力？快分享你的购买心得吧~');
                }
            });
        });

        @*$('.id_sub').each(function (i, e) {
            $(e).bind('click', function () {
                var uid = $(e).attr('data'),
                    star = $('#' + uid + ' .commstar').attr('data'),
                    cont = $('#' + uid + ' .id_cont_txt').val();
                alert(uid+" "+ star+" "+cont);
                if (cont == '商品是否给力？快分享你的购买心得吧~') {
                    cont = false;
                }
                if (!star) {
                    $('#' + uid + ' .id_star').show();
                }
                if (!cont || (cont.length >= 150)) {
                    $('#' + uid + ' .id_cont').show();
                    return;
                }
                if (star && cont) {
                    $.ajax({
                        type: 'post',
                        url: "@Url.Action("AddComment")",
                        data: { star: star, content: cont, suborderid: uid },
                        dataType: "json",
                        success: function (data) {
                            $('#' + uid).hide('200');
                            $('.pj').each(function (i, e) {
                                if ($(e).attr('catethird') == uid) {
                                    $(e).html('已评价');
                                    $(e).attr('catethird', 0);
                                    $(e).append('<br/>');
                                }
                            });
                        }
                    });
                }
            });
        });*@
        $('.pj').each(function (i, e) {
            $(e).bind('click', function () {
                var id = $(e).attr('catethird');
                uid = id;
                if ($('#' + id).css('display') == 'block') {
                    $('#' + id).slideUp(100);
                } else {
                    $('#' + id).slideDown(100);
                }
            });
        });
    }(jQuery));
</script>
